import { Meta } from '@storybook/blocks';

import * as FormStories from '../stories/Form.stories';

<Meta of={FormStories} />

# Form

An optional container for grouping together multiple form field widgets (e.g. TextField widgets).

## Example

```dart liveslice=Form
final _formKey = GlobalKey<FormState>();

@override
Widget build(BuildContext context) {
  return Form(
    key: _formKey,
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        TextFormField(
          validator: (value) {
            if (value.isEmpty) {
              return 'Please enter some text';
            }
            return null;
          },
        ),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 16.0),
          child: RaisedButton(
            onPressed: () {
              // Validate will return true if the form is valid, or false if
              // the form is invalid.
              if (_formKey.currentState.validate()) {
                // Process data.
              }
            },
            child: Text('Submit'),
          ),
        ),
      ],
    ),
  );
}
```

## Related Links

- https://api.flutter.dev/flutter/widgets/Form-class.html
